const os = (function () {
  var ua = navigator.userAgent,
    isWindowsPhone = /(?:Windows Phone)/.test(ua),
    isSymbian = /(?:SymbianOS)/.test(ua) || isWindowsPhone,
    isAndroid = /(?:Android)/.test(ua),
    isFireFox = /(?:Firefox)/.test(ua),
    isChrome = /(?:Chrome|CriOS)/.test(ua),
    isTablet = /(?:iPad|PlayBook)/.test(ua) || (isAndroid && !/(?:Mobile)/.test(ua)) || (isFireFox && /(?:Tablet)/.test(ua)),
    isPhone = /(?:iPhone)/.test(ua) && !isTablet,
    isPc = !isPhone && !isAndroid && !isSymbian,
    isWechat = /(MicroMessenger)/i.test(ua),
    isUC = /(UCBrowser)/i.test(ua),
    isIOS = /(iPhone|iPad|iPod|iOS)/i.test(ua),
    isMobile = !isPc,
    isAlipay = /Alipay/i.test(ua)
  return {
    isTablet: isTablet,
    isPhone: isPhone,
    isAndroid: isAndroid,
    isPc: isPc,
    isMobile: isMobile,
    isUC: isUC,
    isIOS: isIOS,
    isWechat: isWechat,
    isChrome: isChrome,
    isAlipay: isAlipay
  }
})()

export default os
